package com.tvunetworks.center.device.util;

import lombok.Data;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author Ethan
 * @program:
 * @description:
 * @create: 2022/1/18 18:00
 **/
@Data
public class RandomUtil {
    /**
     *
     */
    private static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current();

    /**
     * 随机
     * @param length 长度
     * @return 字符串
     */
    public static String generateString(int length) {
        StringBuilder sb = new StringBuilder();

        for(int i = 0; i < length; ++i) {
            sb.append("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(RANDOM.nextInt("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".length())));
        }

        return sb.toString();
    }
}
